#include<iostream>
#include<vector>
#include<unordered_set>
using namespace std;

class RandomizedSet {
    unordered_set<int> se;
    int digit = 0;
public:
    RandomizedSet() {

    }

    bool insert(int val) {
        if (se.count(val)) {
            return false;
        }
        se.insert(val);
        return true;
    }

    bool remove(int val) {
        if (se.count(val)) {
            se.erase(val);
            return true;
        }
        return false;
    }

    int getRandom() {
        int tmp = 0;
        digit += random();
        digit %= se.size();
        for (auto e : se) {
            if (digit == tmp)
                return e;
            tmp++;
        }
        return -1;
    }

};

/**
 * Your RandomizedSet object will be instantiated and called as such:
 * RandomizedSet* obj = new RandomizedSet();
 * bool param_1 = obj->insert(val);
 * bool param_2 = obj->remove(val);
 * int param_3 = obj->getRandom();
 */